package com.xuda.springboot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ：程序员徐大大
 * @description：TODO
 * @date ：2022-03-20 20:49
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("redirect:/login");
        registry.addViewController("login").setViewName("login");
        registry.addViewController("login.html").setViewName("login");
        registry.addViewController("register").setViewName("regist");

        registry.addViewController("addEmp").setViewName("addEmp");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/register","/user/login","/css/**","/js/**","/img/**","/user/register","/login","/login.html");
    }
}
